using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;

namespace PageDraw
{
    public class GraphicsTree
    {
        private List<TreeNode> drawObjects = new List<TreeNode>();

        public List<TreeNode> DrawObjects
        {
            get { return drawObjects; }
            set { drawObjects = value; }
        }

        public void AddDrawObject(DrawObject drawObject)
        {
            TreeNode node = new TreeNode();
            node.Tag = drawObject;
            drawObjects.Add(node);
        }

        public void Draw(DrawArea drawArea, Graphics g)
        {
            foreach (TreeNode node in drawObjects)
            {
                DrawObject drawObject = node.Tag as DrawObject;
                if (drawObject != null)
                {
                    drawObject.Draw(drawArea, g);
                }
            } 
        }

        public void InsertDrawObject(DrawObject obj)
        {
            TreeNode node = new TreeNode();
            node.Tag = obj;
            drawObjects.Insert(0, node);
        }
    }
}
